package com.hubei.listener;

import com.hubei.dao.DepartmentDao;
import com.hubei.dao.DictDao;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.Map;

@WebListener
public class ApplicationListener implements ServletContextListener {
    public ApplicationListener(){

    }
    public void contextInitialized(ServletContextEvent sce)
    {
        ServletContext application = sce.getServletContext();
        DictDao dictDao = DictDao.getInstance();
        Map<String, String> jobMap = dictDao.getJobType();
        application.setAttribute("jobMap", jobMap);

        DepartmentDao departDao = DepartmentDao.getInstance();
        Map<String, String> departMap = departDao.getDepartment();
        application.setAttribute("departMap", departMap);

    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}